#include "mousemovescrollarea.h"
#include <QMouseEvent>
#include <QScrollBar>

MouseMoveScrollArea::MouseMoveScrollArea ( QWidget* parent ) : QScrollArea ( parent )
{
    mCurrentWidget = new QQtColorWidget ( this->widget() );
    mCurrentWidget->setColor ( QRgb ( 0xFFBBCC ) );
    mCurrentWidget->setHidden ( true );
}


void MouseMoveScrollArea::mousePressEvent ( QMouseEvent* event )
{
    mY = event->pos().y();
    return QScrollArea::mousePressEvent ( event );
}

void MouseMoveScrollArea::mouseReleaseEvent ( QMouseEvent* event )
{
    mY = event->pos().y();
    return QScrollArea::mouseReleaseEvent ( event );
}

void MouseMoveScrollArea::mouseMoveEvent ( QMouseEvent* event )
{
    QPoint currentPt = event->pos();

    int dist = mY - currentPt.y();
    //dist *= 1.5;//加快运动速度
    verticalScrollBar()->setValue ( verticalScrollBar()->value() + dist );
    mY = currentPt.y();

    return QScrollArea::mouseMoveEvent ( event );
}
